<template>
  <div class="school">
    <h2>学校名称:{{ name }}</h2>
    <h2>学校地址:{{ address }}</h2>
  </div>
</template>

<script>
export default {
  name: "School",
  data() {
    return {
      name: "三峡学院",
      address: "重庆",
    };
  },
  mounted() {
    //在全局中线中绑定事件
    this.$bus.$on("hello", (name) => {
      console.log("我是school组件，我收到了student的name:", name);
    });
  },
  //在组件销毁前把绑定的自定义事件解绑，留出空间
  beforeDestroy() {
    this.$bus.$off("hello");
  },
};
</script>
<style scoped>
.school {
  padding: 5px;
  background-color: skyblue;
}
</style>

